<div class="box-content">
    <form class="form-horizontal" method="post">
        <fieldset>
            <tr>
    			  <th>DS SV lam khao sat:</th>
    			  <th>&nbsp;</th>
    		  </tr>
              <div class="control-group">
				<label class="control-label" for="stid">Loai Khao Sat:</label>
				<div class="controls">
					<select id="stid" name="stid" class="span" data-rel="chosen" onchange="ajaxFunction(this.value);">
                        <option></option>
                        <?php foreach($stlist as $row){?>
						     <option value="<?php echo $row['survey_type_id'];?>"><?php echo $row['survey_type_name']; ?></option>
                        <?php };?>
					</select>
                    <input type="hidden" id="st_id" name="st_id"/>
				</div>
               </div>
               <div id="normal-year">
               <?php if($stypeid != null){ ?>
                    <div index="<?php echo $stypeid ?>" class="control-group">
                        <label class="control-label" for="year">Nam:</label>
                        <div class="controls">
                            <div class="input-append">
                                <select id="year" name="year" size="16" data-rel="chosen">
                                    <option></option>
                                    <?php 
                                        foreach($slist as $row){ ?>
                                        <option value="<?php echo $row['survey_id'] ; ?>"> 
                                                        <?php echo $row['start_date']."-".$row['survey_name'] ?> 
                                         </option>
                                    <?php } ?>
                        		</select>
                                <input type="hidden" id="yea" name="yea"/>
                            </div>
                        </div>
                    </div>
               <?php }?>
               </div>
               <div class="control-group">
				<label class="control-label" for="facul">Khoa:</label>
				<div class="controls">
					<select id="facul" name="facul" class="span8" data-rel="chosen">
                        <option></option>
                        <?php foreach($faculty as $row){?>
						     <option value="<?php echo $row['faculty_id'];?>"><?php echo $row['faculty_name']; ?></option>
                        <?php };?>
					</select>
                    <input type="hidden" id="faculty" name="faculty"/>
				</div>
                
                <div class="control-group">
					<label class="control-label" for="percen">Ngau Nhien:</label>
					<div class="controls">
						<select id="percen" name="percen" class="span8" data-rel="chosen">
                            <option value="5">5 %</option>
                            <option value="10">10%</option>
                            <option value="20">20%</option>
                            <option value="30">30%</option>
                            <option value="40">40%</option>
                            <option value="50">50%</option>
                            <option value="60">60%</option>
                            <option value="70">70%</option>
                            <option value="80">80%</option>
                            <option value="90">90%</option>
                            <option value="100">100%</option>
						</select>
                        <input type="hidden" id="per" name="per"/>
					</div>
               </div>
               
               <div class="form-actions">
                    <button type="submit" name="submit" value="search" class="btn btn-primary">Ngau nhien: </button>
                    <button type="submit" name="submit" value="find" class="btn btn-primary">Tim: </button>
               </div>
                       </fieldset>
    </form>
</div>
               <!----------->
     <div class="box-content">
			<table class="table">
				  <thead>
					  <tr>
						  <th>Danh sach Sinh Vien</th>
						  <th>&nbsp;</th>
					  </tr>
				  </thead>   
				  <tbody>


                      <?php if($valilist!=null){?>
                        <?php $l=0;
                            foreach($valilist as $row){?>
                        <tr>
                            <td> 
                                <?php echo $row['student_id'];?> 
                                &nbsp;
                                <?php echo $row['first_name'];?> 
                                &nbsp;
                                <?php echo $row['last_name'];?>
                                &nbsp;
                                <?php echo $row['class_id'];?>
                                &nbsp;
                                <?php echo $row['contact_address'];?>  
                                &nbsp;&nbsp;&nbsp;
                                <?php echo $row['note'];?>
                                &nbsp;&nbsp;&nbsp;
                                <?php   if($row['value'] == 1)
                                            echo "Thong tin dung";
                                        elseif($row['value'] == 2)
                                            echo "Thong tin sai";
                                        else
                                            echo "Chua xac thuc";?>
                            </td>
                            <td class="right">
                                <?php
                                if($anslist!=null){
                                    $n=0;
                                    foreach($anslist[$l] as $r){ ?>
                                        </br>
                                        <?php echo $r['content']?>
                                        </br>
                                 <?php   $n++;
                                    } 
                                }
                                ?>
                            </td>
                        </tr>
                        <tr>
                                <td class="right">
                                 <div class="box-content">
                                 <form class="form-horizontal" method="post" >
                                    <fieldset>
                                        <div class="control-group">
                                            <input type="hidden" class="inforid<?php echo $l?>" name="inforid" value="<?php echo $row['infor_id']?>" />
                                            <input type="hidden" class="validati<?php echo $l?>" name="validati" value="<?php echo $row['validation_id']?>" />    
                                        </div>
                    					<a class="btn btn-info btn-setting true" index="<?php echo $l?>" href="#true">
                    						<i class="icon-edit icon-white"></i>
                    						Dung
                    					</a>
                    					<a class="btn btn-danger btn-setting false" index="<?php echo $l?>" href="#false">
                    						<i class="icon-trash icon-white"></i> 
                    						Sai
                    					</a>
                                        <div class="controls">
                                                <input type="hidden" class="valida<?php echo $l?>" name="valida" value="0"/>
                                        </div> 
                                        <div class="form-actions">
                                            <div class="controls">
                                                <input class="input-xlager span8 note<?php echo $l?>" type="text" name="note"/>
                                            </div>
                                            <a class="btn btn-success validation" index="<?php echo $l?>" href="#validationmodal">
                                            
                                            Luu</a>
                                        </div>
                                    </fieldset>
                                 </form>
                                </div>
            				    </td>
                              </tr>   
                        <?php $l++;}?>
                      <?php }?>
                  </tbody>
            </table>
        </div>

<script type="text/javascript" >
    $(document).ready(function(){
        //chen combo box
        $('#stid').change(function(){
            $('#st_id').val($('#stid').val());
            //alert( $('#stid').val());
            var stid = $('#stid').val();
            $.get("Validation/load_survey/" + stid,function(data,result){
                if(result=='success')
                    $('#normal-year').html(data);
            });
        });
        //xu li chon xac thuc
        $('.true').click(function(){
            //alert('dad');
            var index = $(this).attr('index');
            $('.valida'+index).val("1");
             //valu = $('.valida'+index).val();
        });
        //xu li chon xac thuc
        $('.false').click(function(){
            var index = $(this).attr('index');
            $('.valida'+index).val("2");
             //valu = $('.valida'+index).val();
        });
        //lay survey
        $('#year').change(function(){
            $('#yea').val($('#year').val());
            //alert( $('#yea').val());
        });
        //lay khoa
        $('#facul').change(function(){
            $('#faculty').val($('#facul').val());
            //alert( $('#faculty').val());
        });
        //lay %
        $('#percen').change(function(){
            //$number = $('#percen').val();
            //alert($number);
            $('#per').val($('#percen').val());
            //$num2 = $('#per').val();
            //alert($num2);
        });
        $('.validation').click(function(){
            var index = $(this).attr('index');
            var infor = $('.inforid'+index).val();
            
            var vali_id = $('.validati'+index).val();
            alert(vali_id);
            //alert(infor);
            //alert(index);
            //var val_id = $(this).attr("inforid");
            //alert(infor);
            //alert(valu);
            var not = $('.note'+index).val();
            //alert(not);
            var valu = $('.valida'+index).val();
            $.get('Validation/validation_infor/' + vali_id + '/' + valu + '/' + not,function(result){
                //alert(result);
                	if(result == 'success'){
                	   alert("xong");
                	}
                    //else{alert("die")}
            });
        });
        
    });
</script>
